//-----------------------------------------------------------------------
// <copyright file="MLTreeTag.cs" company="MAPILab Ltd">
//     Copyright (c) MAPILab Ltd.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace MAPILab.SharePoint.Explorer.ObjectBrowser
{
    using System;

    /// <summary>
    /// treetag for object tree from object browser
    /// </summary>
    class MLTreeTag
    {
        #region Fields

        /// <summary>
        /// Object type
        /// </summary>
        private Type objectDeclaringType;

        /// <summary>
        /// Class name
        /// </summary>
        private string className;

        /// <summary>
        /// Object
        /// </summary>
        private object objInstance;

        /// <summary>
        /// Has persisted object role
        /// </summary>
        private bool persistedObjectRole = false;

        /// <summary>
        /// Is folder node
        /// </summary>
        private bool syntetic = false;

        #endregion

        #region Properties

        /// <summary>
        /// Gets and sets object type
        /// </summary>
        public Type ObjectDeclaringType
        {
            get { return objectDeclaringType; }
            set { objectDeclaringType = value; }
        }

        /// <summary>
        /// Gets and sets class name
        /// </summary>
        public string ClassName
        {
            get { return className; }
            set { className = value; }
        }

        /// <summary>
        /// Gets and sets object
        /// </summary>
        public object ObjInstance
        {
            get { return objInstance; }
            set { objInstance = value; }
        }

        /// <summary>
        /// Gets and sets persisted object role
        /// </summary>
        public bool PersistedObjectRole
        {
            get { return persistedObjectRole; }
            set { persistedObjectRole = value; }
        }

        /// <summary>
        /// Gets and sets syntetic
        /// </summary>
        public bool Syntetic
        {
            get { return syntetic; }
            set { syntetic = value; }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="objInstance">object</param>
        /// <param name="objectDeclaringType">object type</param>
        public MLTreeTag(object objInstance, Type objectDeclaringType)
        {
            Initialize(objInstance, objectDeclaringType, false);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="objInstance">object</param>
        /// <param name="objectDeclaringType">object type</param>
        /// <param name="syntetic">Is folder node</param>
        public MLTreeTag(object objInstance, Type objectDeclaringType, bool syntetic)
        {
            Initialize(objInstance, objectDeclaringType, syntetic);
        }

        #endregion

        #region Methods

        /// <summary>
        /// Initialize fields
        /// </summary>
        /// <param name="objInstance">object</param>
        /// <param name="objectDeclaringType">object type</param>
        /// <param name="syntetic">is folder node</param>
        private void Initialize(object objInstance, Type objectDeclaringType, bool syntetic)
        {
            if (objInstance != null)
                this.className = objInstance.GetType().ToString();

            if (objectDeclaringType != null)
            {
                this.objectDeclaringType = objectDeclaringType;
            }

            this.objInstance = objInstance;
            this.syntetic = syntetic;
        }

        #endregion
    }
}
